/*
 * @Author: lll 1280388921@qq.com
 * @Date: 2025-05-13 20:19:47
 * @LastEditors: lll 1280388921@qq.com
 * @LastEditTime: 2025-05-13 20:26:37
 * @FilePath: /lesson40/3.Thread/main.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <iostream>
#include <unistd.h>
#include <vector>
#include "Thread.hpp"

using namespace std;

void print()
{
    while (1)
    {
        cout << "我是一个被封装的线程..." << endl;
        sleep(1);
    }
}

int main()
{
    // 多线程
    vector<Thread> threads;
    for (int i = 0; i < 5; i++)
    {
        threads.push_back(Thread(print));
    }

    for (auto &t : threads)
    {
        t.Run();
    }

    for (auto &t : threads)
    {
        t.Join();
    }

    // 单线程
    //  Thread t(print);

    // t.Run();

    // cout<<"是否启动成功: "<<t.IsRunning()<<endl;
    // cout<<"name: "<<t.Name()<<endl;
    // cout<<"starttime: "<<t.StartTime()<<endl;

    // t.Join();

    return 0;
}
